//
//  ViolationCodeViewController.swift
//  TrafficViolation
//
//  Created by clover on 2017/5/3.
//  Copyright © 2017年 eaglelive. All rights reserved.
//

import UIKit

class ViolationCodeViewController: UIViewController {
    var code:String!
    var codeTable:UITableView!//数据表格
    var codeArray: [ViolationCodeModel] = Array<ViolationCodeModel>()
    override func viewDidLoad() {
        super.viewDidLoad()
        //初始化表格
        codeTable = UITableView(frame: CGRect(x:0,y:kStatusBarH + kNavigationBarH + 40,width:kScreenW,height:kScreenH - kStatusBarH - kNavigationBarH - 40),style: UITableViewStyle.plain)
        codeTable?.delegate = self
        codeTable?.dataSource = self
        codeTable?.backgroundColor = tableBgColor
        codeTable?.rowHeight = UITableViewAutomaticDimension
        codeTable?.estimatedRowHeight = 45.0
        codeTable?.separatorStyle = UITableViewCellSeparatorStyle.none
        codeTable.register(UITableViewCell.self, forCellReuseIdentifier: "codeCellID")
        self.view.addSubview(codeTable!)
    }
}
extension ViolationCodeViewController:UITableViewDelegate, UITableViewDataSource{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return codeArray.count
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell: ViolationCodeCell? = tableView.dequeueReusableCell(withIdentifier: "codeCellID") as? ViolationCodeCell
        if cell == nil {
            cell = ViolationCodeCell(style: UITableViewCellStyle.subtitle,reuseIdentifier: "codeCellID")
        }
        if codeArray.count > 0 {
            let model = codeArray[(indexPath as NSIndexPath).row]
            cell?.configCellDateWithModel(model)
        }
        return cell!
    }
}
